﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Resume.Data.Model;

namespace Resume.Data.Mappers
{
    public class SummaryMapper : EntityTypeConfiguration<Summary>
    {
        public SummaryMapper()
        {
            this.ToTable("Summaries");

            this.HasKey(p => p.Id);
            this.Property(p => p.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(p => p.Id).IsRequired();

            this.Property(p => p.Name).IsOptional();
            this.Property(p => p.Name).HasMaxLength(100);

            this.Property(p => p.Description).IsOptional();
            this.Property(p => p.Description).HasMaxLength(1000);

            this.HasMany(s => s.Resumes)
                .WithOptional(r => r.Summary)
                .HasForeignKey(r=>r.SummaryId);

        }
    }
}
